﻿using MyMathLib;
namespace LeastSquareMethod
{
    internal class Program
    {
        /// <summary>
        /// 用最小二乘法拟合并预测2021年GDP
        /// </summary>
        /// <param name="args"></param>
        static void Main(string[] args)
        {
            //从文件中读取数据
            var model = new MyMath();
            model.X = DataFetch.ListReadTxt(@$"{System.Environment.CurrentDirectory}\Year.txt");
            model.Y = DataFetch.ListReadTxt(@$"{System.Environment.CurrentDirectory}\GDP.txt");
            //计算
            model.Comput();
            //预测
            var Gdp = model.Forecast(2021);
            Console.WriteLine($"预测2021年的GDP为{Gdp.ToString("##.##")}万亿美元");
        }
    }
}